calculate profit and loss